package com.learn.reflect;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by chenxin on 2017/8/1.
 */
public class IServiceProxy implements InvocationHandler {
    private Object target;

    IServiceProxy(Object target){
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//        return method.invoke(target, args);
        try {
            return method.invoke(target, args);
        } catch (InvocationTargetException e){
            throw e.getCause();
        }

    }
}
